home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Snippets / OS Utilities / TestGestalt / TestQD / TestGestalt.c < prev   
Encoding:
C/C++ Source or Header  |  1994-11-12  |  1.5 KB  |  73 lines  |  [TEXT/MPS ]

  1. #ifndef __CTYPE__
  2. #include <CType.h>
  3. #endif
  4.  
  5. #ifndef __OSUTILS__
  6. #include <OSUtils.h>
  7. #endif
  8.  
  9. #ifndef __STDIO__
  10. #include <StdIO.h>
  11. #endif
  12.  
  13. #ifndef __GESTALTEQU__
  14. #include <GestaltEqu.h>
  15. #endif
  16.  
  17. #ifndef __TYPES__
  18. #include <Types.h>
  19. #endif
  20.  
  21. #define    TRUE            0xFF
  22. #define    FALSE            0
  23.  
  24.  
  25. // check to see if a given trap is implemented. We follow IM VI-3-8.
  26. Boolean TrapAvailable(short theTrap)
  27. {
  28.     TrapType theTrapType;
  29.     short numToolboxTraps;
  30.     
  31.     if ((theTrap & 0x0800) > 0)
  32.         theTrapType = ToolTrap;
  33.     else
  34.         theTrapType = OSTrap;
  35.  
  36.     if (theTrapType == ToolTrap)
  37.     {
  38.         theTrap = theTrap & 0x07ff;
  39.         if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xaa6e, ToolTrap))
  40.             numToolboxTraps = 0x0200;
  41.         else
  42.             numToolboxTraps = 0x0400;
  43.         if (theTrap >= numToolboxTraps)
  44.             theTrap = _Unimplemented;
  45.     };
  46.  
  47.     return (NGetTrapAddress(theTrap, theTrapType) != NGetTrapAddress(_Unimplemented, ToolTrap));
  48. }
  49.  
  50.  
  51. main()
  52. {
  53. OSErr        err;
  54. long        feature;
  55.  
  56. if (TrapAvailable(_Gestalt)) {
  57.     err = Gestalt(gestaltQuickdrawVersion, &feature);
  58.     if (!err) {
  59.         if ((feature & 0x0f00) == 0x0000)
  60.             printf ("We have Original QuickDraw version 0.%x\n", (feature & 0x00ff));
  61.         else if ((feature & 0x0f00) == 0x0100)
  62.             printf ("We have 8 Bit QuickDraw version 1.%x\n", (feature & 0x00ff));
  63.         else if ((feature & 0x0f00) == 0x0200)
  64.             printf ("We have 32 Bit QuickDraw version 2.%x\n", (feature & 0x00ff));
  65.         else
  66.             printf ("We don't have QD\n");
  67.         }
  68.     else 
  69.         printf ("Gestalt err = %i\n",err);
  70.     }
  71. else
  72.     printf ("No Gestalt\n");
  73. }